<?php

use think\facade\Route;
use think\facade\Request;

$version = Request::header('version', 'v1');#接口版本
Route::group('', function () use ($version) {
    // 登录
    Route::group('site', function () use ($version) {
        Route::post('login', "backend/{$version}.Site/login");
    });

    // 后台用户管理
    Route::group('backendMember', function () use ($version) {
        Route::get(':id', "backend/{$version}.BackendMember/index");
        //  获取后台角色信息
        Route::get('get-role', "backend/{$version}.BackendMember/getrole");
        //  清除缓存
        Route::get('clear-cache', "backend/{$version}.BackendMember/clearcache");
    })->middleware('checkLogin');

    // 会员管理
    Route::group('member', function () use ($version) {
        Route::get('index', "backend/{$version}.Member/index");
        Route::post('create', "backend/{$version}.Member/create");
        Route::put('update', "backend/{$version}.Member/update");
        Route::delete('delete', "backend/{$version}.Member/delete");
    });

    // 轮播管理
    Route::group('banner', function () use ($version) {
        Route::get('index', "backend/{$version}.Banner/index");
        Route::post('create', "backend/{$version}.Banner/create");
        Route::post('update', "backend/{$version}.Banner/update");
        Route::delete('delete', "backend/{$version}.Banner/delete");
        Route::get('search', "backend/{$version}.Banner/search");
        Route::post('uploads_file', "backend/{$version}.Banner/uploads_file");
    });

    // 分类
    Route::group('classify', function () use ($version) {
        Route::get('index', "backend/{$version}.Classify/index");
        Route::post('create', "backend/{$version}.Classify/create");
        Route::post('update', "backend/{$version}.Classify/update");
        Route::delete('delete', "backend/{$version}.Classify/delete");
        Route::post('search', "backend/{$version}.Classify/search");
    });

    // 列表
    Route::group('listing', function () use ($version) {
        Route::get('index', "backend/{$version}.Listing/index");
        Route::post('create', "backend/{$version}.Listing/create");
        Route::post('update', "backend/{$version}.Listing/update");
        Route::delete('delete', "backend/{$version}.Listing/delete");
        Route::post('search', "backend/{$version}.Listing/search");
        Route::post('uploads_file', "backend/{$version}.Listing/uploads_file");
    });

    // 动态
    Route::group('dynamic', function () use ($version) {
        Route::get('index', "backend/{$version}.Dynamic/index");
        Route::post('create', "backend/{$version}.Dynamic/create");
        Route::post('update', "backend/{$version}.Dynamic/update");
        Route::delete('delete', "backend/{$version}.Dynamic/delete");
        Route::post('search', "backend/{$version}.Dynamic/search");
        Route::post('uploads_file', "backend/{$version}.Dynamic/uploads_file");
    });

    // 案例管理
    Route::group('casus', function () use ($version) {
        Route::get('index', "backend/{$version}.Casus/index");
        Route::post('create', "backend/{$version}.Casus/create");
        Route::post('update', "backend/{$version}.Casus/update");
        Route::delete('delete', "backend/{$version}.Casus/delete");
        Route::get('search', "backend/{$version}.Casus/search");
        Route::post('uploads_file', "backend/{$version}.Casus/uploads_file");
    });
    // 整形医生
    Route::group('doctor', function () use ($version) {
        Route::get('index', "backend/{$version}.Doctor/index");
        Route::post('create', "backend/{$version}.Doctor/create");
        Route::post('update', "backend/{$version}.Doctor/update");
        Route::delete('delete', "backend/{$version}.Doctor/delete");
        Route::post('search', "backend/{$version}.Doctor/search");
        Route::post('uploads_file', "backend/{$version}.Doctor/uploads_file");
    });
    // 视频管理
    Route::group('video', function () use ($version) {
        Route::get('index', "backend/{$version}.Video/index");
        Route::post('create', "backend/{$version}.Video/create");
        Route::post('update', "backend/{$version}.Video/update");
        Route::delete('delete', "backend/{$version}.Video/delete");
        Route::post('uploads_video', "backend/{$version}.Video/uploads_video");
    });

    // 预约管理
    Route::group('subscribe', function () use ($version) {
        Route::get('index', "backend/{$version}.Subscribe/index");
        Route::delete('delete', "backend/{$version}.Subscribe/delete");
    });

})->allowCrossDomain([
    'Access-Control-Allow-Origin' => '*',
    'Access-Control-Allow-Methods' => 'GET,POST,DELETE',
    'Access-Control-Allow-Headers' => 'content-type,token,version',
    'Access-Control-Allow-Credentials' => 'true'
]);